<?php
namespace app\common\model\video;
use think\Model;

class VideoUser extends Model{
    // 表名
    protected $name = 'video_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [];


    /**
     * [genUserNumber 生成会员号]
     * @Author   ZhouYunpeng
     * @DateTime 2022-04-25
     * @param    [type]      $user_id [description]
     * @param    [type]               [description]
     */
    public function genUserNumber($user_id)
    {
        $userIdLen = strlen($user_id);
        $length = 12 - $userIdLen;
        $char = '0123456789abcdefghijklmnopqrstuvwxyz';
        
        if(!is_int($length) || $length < 0) {
            return false;
        }

        $string = '';
        for($i = $length; $i > 0; $i--) {
            $string .= $char[mt_rand(0, strlen($char) - 1)];
        }
        $string =  str_shuffle($string.$user_id);
        return $string;
    }
    
}
